/*
 *      Copyright (c) 2018-2028, DreamLu All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: DreamLu 卢春梦 (596392912@qq.com)
 */
package com.example.demo1.util;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.http.entity.ContentType;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * Http请求工具类
 *
 * @author Chill
 */
@Slf4j
public class OkHttpUtil {

	private static int connTimeOut = 5;
	private static int readTimeOut = 20;
	private static int writeTimeOut = 10;
	public static OkHttpClient client = null;

	static {
		client = new OkHttpClient.Builder()
				.connectTimeout(5L, TimeUnit.SECONDS)
				.readTimeout(20L, TimeUnit.SECONDS)
				.writeTimeout(5L, TimeUnit.SECONDS)
				.sslSocketFactory(SSLSocketClient.getSSLSocketFactory(), SSLSocketClient.getX509TrustManager())//ssl配置跳过
				.hostnameVerifier(SSLSocketClient.getHostnameVerifier())//ssl配置跳过
				.retryOnConnectionFailure(true)
				.build();
	}

	public static MediaType JSON = MediaType.parse("application/json;charset=utf-8");
	public static MediaType XML = MediaType.parse("application/xml;charset=utf-8");
	private static final MediaType SOAP_XML = MediaType.parse("application/soap+xml;charset=utf-8");

	/**
	 * GET
	 *
	 * @param url     请求的url
	 * @param queries 请求的参数，在浏览器？后面的数据，没有可以传null
	 * @return String
	 */
	public static String get(String url, Map<String, Object> queries) {
		return get(url, null, queries);
	}

	/**
	 * GET
	 *
	 * @param url     请求的url
	 * @param header  请求头
	 * @param queries 请求的参数，在浏览器？后面的数据，没有可以传null
	 * @return String
	 */
	public static String get(String url, Map<String, String> header, Map<String, Object> queries) {
		StringBuffer sb = new StringBuffer(url);
		if (queries != null && queries.keySet().size() > 0) {
			queries.forEach((k, v) -> sb.append("&").append(k).append("=").append(v));
		}
		Request.Builder builder = new Request.Builder();


		if (header != null && header.keySet().size() > 0) {
			header.forEach(builder::addHeader);
		}

		Request request = builder.url(sb.toString()).build();
		return getBody(request);
	}

	/**
	 * POST
	 *
	 * @param url    请求的url
	 * @param params post form 提交的参数
	 * @return String
	 */
	public static String post(String url, Map<String, String> params) {
		return post(url, null, params);
	}

	/**
	 * POST
	 *
	 * @param url    请求的url
	 * @param header 请求头
	 * @param params post form 提交的参数
	 * @return String
	 */
	public static String post(String url, Map<String, String> header, Map<String, String> params) {
		FormBody.Builder formBuilder = new FormBody.Builder();
		//添加参数
		if (params != null && params.keySet().size() > 0) {
			params.forEach(formBuilder::add);
		}

		Request.Builder builder = new Request.Builder();

		if (header != null && header.keySet().size() > 0) {
			header.forEach(builder::addHeader);
		}

		Request request = builder.url(url).header("Connection", "close").post(formBuilder.build()).build();
		return getBody(request);
	}

	/**
	 * POST请求发送JSON数据
	 *
	 * @param url     请求的url
	 * @param json    请求的json串
	 * @return String
	 */
	public static String postJson(String url, String json) {
		return postJson(url, null, json);
	}

	/**
	 * POST请求发送JSON数据
	 * @param url     请求的url
	 * @param header  请求头
	 * @param json    请求的json串
	 * @return String
	 */
	public static String postJson(String url, Map<String, String> header, String json) {
		return postContent(url, header, json, JSON);
	}

	/**
	 * POST请求发送xml数据
	 *
	 * @param url     请求的url
	 * @param xml     请求的xml串
	 * @return String
	 */
	public static String postXml(String url, String xml) {
		return postXml(url, null, xml);
	}

	/**
	 * POST请求发送xml数据
	 *
	 * @param url     请求的url
	 * @param header  请求头
	 * @param xml     请求的xml串
	 * @return String
	 */
	public static String postXml(String url, Map<String, String> header, String xml) {
		return postContent(url, header, xml, XML);
	}

	/**
	 * 发送POST请求
	 *
	 * @param url     请求的url
	 * @param header  请求头
	 * @param content 请求内容
	 * @param mediaType 请求类型
	 * @return String
	 */
	public static String postContent(String url, Map<String, String> header, String content, MediaType mediaType) {
		RequestBody requestBody = RequestBody.create(mediaType, content);
		Request.Builder builder = new Request.Builder();
		if (header != null && header.keySet().size() > 0) {
			header.forEach(builder::addHeader);
		}
		Request request = builder.url(url).header("Connection", "close").post(requestBody).build();
		return getBody(request);
	}

	/**
	 * 获取body
	 *
	 * @param request request
	 * @return String
	 */
	private static String getBody(Request request) {
		String responseBody = "";
		Response response = null;
		try {
//			OkHttpClient okHttpClient = new OkHttpClient().newBuilder().connectTimeout(1L, TimeUnit.SECONDS).build();
			response = client.newCall(request).execute();
			log.info("okhttp3 post respose : {} ", response);
			if (response.isSuccessful()) {
				return response.body().string();
			}else{
				log.error("{}", response);
			}
		} catch (Exception e) {
			log.error("okhttp3 post error >> ex = {}", e.getMessage(), e);
		} finally {
			if (response != null) {
				response.close();
			}
		}
		return responseBody;
	}

	public static void close(){
		if (client != null) {
		}
	}

	public static void main(String[] args) throws UnsupportedEncodingException {
//		long start = System.currentTimeMillis();
////		for(int i=0;i<1;i++) {
//			String s = OkHttpUtil.get("http://www.github.com", null);
//			System.out.println(s);
////		}
//		long end = System.currentTimeMillis();
//		System.out.println(String.format("OkHttpUtil 总耗时：%S毫秒 - %S秒", end-start ,(end-start)/1000));

		/*long start = System.currentTimeMillis();
		String url = "http://fy.webxml.com.cn/webservices/EnglishChinese.asmx?wsdl";
		String soapXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"><soap12:Body><TranslatorString xmlns=\"http://WebXml.com.cn/\"><wordKey>test</wordKey></TranslatorString></soap12:Body></soap12:Envelope>";
		String result = postContent(url, null, soapXml, SOAP_XML);
		log.info("webservice =====> result : {}", result);
		long end = System.currentTimeMillis();
		log.info("OkHttpUtil 总耗时：{}毫秒 - {}秒", end-start ,(end-start)/1000);
		for(int i=0;i<10;i++) {
			start = System.currentTimeMillis();
			url = "http://10.242.0.51/data-transfer/ws/RoadTransService?wsdl";
			soapXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><Command xmlns=\"http://roadtrans.service.cttic.cn/\"><transaction xmlns=\"\"><header><serialnum>66000020210720141007752123135785</serialnum><sourceservice>660000</sourceservice><targetservice>000000</targetservice><systemid>000000</systemid><serviceid>QE0101</serviceid><date>20210720</date><time>141007</time><isreq>0</isreq><signature><md5>C6EF49378CA521B0EB08D00D2024A0DC</md5><detail>Qec1HNHF6n0K/RYBmmJTUxI+gQ/bzjQvfLaTly9oUE34iUNMCyj3O0fryIzIFKAn0lxrh2QCOGyYHJSk2MhhsQ==</detail></signature><response></response></header><body>&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;reqInfo&gt;&lt;idCard&gt;130721198306111113&lt;/idCard&gt;&lt;idType&gt;1&lt;/idType&gt;&lt;provinceCode&gt;&lt;/provinceCode&gt;&lt;pageInfo&gt;&lt;page&gt;1&lt;/page&gt;&lt;/pageInfo&gt;&lt;/reqInfo&gt;</body></transaction></Command></soap:Body></soap:Envelope>";
			result = postContent(url, null, soapXml, SOAP_XML);
			log.info("webservice =====> result : {}", result);
			end = System.currentTimeMillis();
			log.info("OkHttpUtil 总耗时：{}毫秒 - {}秒", end - start, (end - start) / 1000);
		}*/

//		String json = "{\"id\":null,\"businessSn\":\"650000999202108020009050\",\"busiType\":\"1030\",\"examineeName\":\"田浩\",\"examineeIdcard\":\"371524199203210213\",\"applyReason\":0,\"examineeSex\":1,\"birthDate\":\"1992-03-21\",\"examineeNation\":4,\"examineeDegree\":4,\"health\":1,\"examineePhone\":\"13542554578\",\"idcardAddress\":\"\",\"currentAddress\":\"\",\"examineeEmail\":\"\",\"professionalTechnology\":\"\",\"planId\":\"1419896111325265922\",\"examineeId\":null,\"subordinateOrganId\":1123598813738675202,\"examinationTypeName\":null,\"pointName\":null,\"commonScore\":null,\"drivingLicenseNum\":\"\",\"quasiDrivingType\":null,\"licenseDate\":null,\"validBeginDate\":\"2021-08-02\",\"validExpireDate\":null,\"licenseIssueOrgan\":\"\",\"updateTime\":null,\"createTime\":null,\"applyDate\":\"20210802153707\",\"certificateInfo\":[{\"imageType\":\"15-本人照片\",\"imgName\":null,\"imgExt\":\"personalPic\",\"base64Binary\":\"/9j/4AAQSkZJRgABAQIAJQAlAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAHFAl8DASIAAhEBAxEB/8QAGgABAQEBAQEBAAAAAAAAAAAAAAECAwUGBP/EAEAQAQABAgMEBAoIBQUBAQAAAAABAhEDITEEQWFxBRIyURMVUlNzgZGSobEUIjVCcnSCsiMzwdHwJDRDYmTh8f/EABsBAQEBAQEBAQEAAAAAAAAAAAABAgMEBQYH/8QAJhEBAAIBAwQCAgMBAAAAAAAAAAERAgMSMQQhIjITgUFhFDNRI//aAAwDAQACEQMRAD8A/MKj98/mgWBREaQVCyoKgqKAChmRMx3iA3153xE80th1burPBlBVnB7qoliaKqdaZhq8tRXMaSUty4o/RM0VdqmPUzOFRV2a7c0pYycB0qwa43Xjg5zExlI1aSLZBUkVJFRGkVUC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kkoKqCTItCF0mVIW6XTPuSqYjfZaapb5pdia43ZszXM8OS9moxbqm2s2ZmumNLzyc55l0tuMVnEq5Qze6JJbUQIXSZLaVmVuzMpamiTJMpMjUQk8CZJlneKsz8RPkDUQmdzfkd6XvE71U3XSZtGXxVmco4CvtkWUcn5sABJAFQAURUFEJAQEVVEAEEFVAFBAEkJSRVEBRJEkWFELgIXJkBFlBQkFVEVkFQBUkJlBSQQUmUJS60pcmUSZKVZlBmaoji01ELMp6mev3ZMTMzrI1EOk1RG9ia+5lC2ohZrmd7PtBLahJlLkg1CShIAzKykyNIkqzI0b0nQTSEURUFhASfaqwJMZ6L8TvFZnXvj5JrOcLOSaTnApJyzI9ichX2oDm/NgAIAKgAsIm8BSUAIEAUAVUkAElNwCgAJKbwFVAFRJAUQAEAUQBQmQBkBVRLgLCXAFEkFVmSM5BVgnLixNUzpkCtMTrnKAy0iTuAahJARYRAVYRJmwCpLIDUF7JICokzvAagQBUT+oCom8BYNJSQGjW7M5TEABzSct1wFf/2Q==\"}]}";
//		json = URLDecoder.decode(json, "UTF-8");
//		Map<String, String> header = new HashMap<>();
//		header.put("Accept", "application/json");
		//ContentType.APPLICATION_JSON.getMimeType()
//		header.put("Content-Type", "application/json;charset=utf-8");
//		json = "{\"Header\":{\"SerialNum\":\"99999720210618000000000000000002\",\"SystemId\":\"999997\",\"Source\":\"999996\",\"Target\":\"999999\",\"Channel\":\"4\",\"IPCType\":\"ML2001\",\"ReqTime\":\"20210618080642\",\"ReqType\":\"0\",\"CRC\":\"11111111111111111111\",\"Token\":\"\",\"Code\":\"\",\"Message\":\"\"},\"Body\":\"\"}";
//		String s = postJson("http://127.0.0.1:9503/NetRoadCGSS-interService/iis/server/location/vehicle/vehicleLocationInfo", json);
//		System.out.println(s);

		String json = "{\"provinceCode\": \"650000\",\"ownerId\": \"127958\",\"pageInfo\":{\"page\":\"1\"}}";
		String token = "bearer eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3N1c2VyIiwiYXVkIjoiYXVkaWVuY2UiLCJ0ZW5hbnRfaWQiOiIwMDAwMDAiLCJyb2xlX25hbWUiOiJhZG1pbmlzdHJhdG9yIiwidXNlcl9pZCI6IjExMjM1OTg4MjE3Mzg2NzUyMDgiLCJyb2xlX2lkIjoiMTEyMzU5ODgxNjczODY3NTIwMSIsInVzZXJfbmFtZSI6ImNoYXJ0ZXJfSlQiLCJuaWNrX25hbWUiOiLmlrDnloblhbXlm6LljIXovaYiLCJ0b2tlbl90eXBlIjoiYWNjZXNzX3Rva2VuIiwiZGVwdF9pZCI6IjExMjM1OTg4MTM3Mzg2NzUyMDEiLCJhY2NvdW50IjoiY2hhcnRlcl9KVCIsImNsaWVudF9pZCI6InN3b3JkIiwiZXhwIjoxNjI5MzU5ODAyLCJuYmYiOjE2MjkzNTYyMDJ9.z8DOsBQ2vCDFPBEN9qa7WaW0TOEdM9zqFRIAp_19mZ8";
		Map<String, String> map =  new HashMap<>();
		map.put("Authorization", "Basic c3dvcmQ6c3dvcmRfc2VjcmV0");
		map.put("Blade-Auth", token);
		Type type = new TypeReference<Map<String, String>>() {
		}.getType();
		Map<String, String> param = JSONObject.parseObject(json, type);
		String s = postJson("http://localhost:9998/api/webService/roadowner/getByOwnerId", map, json);
		System.out.println(s);
	}

}
